Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ektx/v-contextmenu

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ektx/v-contextmenu

Vue 右键菜单功能

  • 0.2.8
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

VContextmenu

右键菜单功能

demo

使用方式

  1. 安装
yarn add @ektx/v-contextmenu
  1. 在 vues 的 state 中添加共享状态与方法

请先确保你有使用 vuex

import VContextmenu from '@ektx/v-contextmenu/store'

const store = new Vuex.Store({
	modules: { VContextmenu }
})
  1. 在页面中调用组件
<template>
	<main>
		<!-- 绑定事件 -->
		<div @contextmenu.prevent="rightClick"></div>

		<!-- 引用 HTML 结构 -->
		<VContextmenus />
	</main>
</template>

<script>
	// 引入
	import VContextmenus from '@ektx/v-contextmenus'

	export default {
		components: {
			VContextmenus
		},
		data () {
			return {
				// 菜单内容
				menu: {
					data: [
						{
							title: 'v-contenxtmenus',
							classes: 'hello',
							evt (data) {
								alert('Welcome Use v-contenxtmenus!')
							}
						},
						{
							title: '联系方式',
							children: [
								{
									title: 'ektx1989@gmail.com'
								},
								{
									title: '@宅龙猫'
								}
							]
						},
						{
							type: 'separator'
						},
						{
							title: 'Github.com',
							evt () {

							}
						},
						{
							type: 'separator'
						},
						{
							disabled: true,
							title: 'v 0.1.0'
						}
					]
				}
			}
		},
		methods: {
			// 自定义事件
			rightClick (evt) {
				this.$store.commit('setContextmenu', {
					data: this.menu, evt
				})
			}
		}
	}
</script>

事件方法

  • 展示菜单功能

store.commit('setContextmenu', {data, evt})

@data 菜单内容 @evt 鼠标事件

  • 关闭菜单

store.commit('setContextmenu', { show: false })

FAQs

Package last updated on 27 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc